package wiki.douzi.helpyougrow.service.impl;

import wiki.douzi.helpyougrow.domain.RoomOrder;
import wiki.douzi.helpyougrow.mapper.RoomOrderMapper;
import wiki.douzi.helpyougrow.service.RoomOrderService;
import org.springframework.stereotype.Service;

import java.util.List;
import javax.annotation.Resource;

/**
 * (RoomOrder)表服务实现类
 *
 * @author Douzi
 * @since 2022-06-18 16:39:23
 */
@Service("roomOrderService")
public class RoomOrderServiceImpl implements RoomOrderService {
    @Resource
    private RoomOrderMapper roomOrderMapper;

    /**
     * 查询所有数据
     *
     * @return 实例对象集合
     */
    @Override
    public List<RoomOrder> queryAll() {
        return this.roomOrderMapper.queryAll();
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public RoomOrder queryById(Integer id) {
        return this.roomOrderMapper.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param roomOrder 实例对象
     * @return 实例对象
     */
    @Override
    public RoomOrder insert(RoomOrder roomOrder) {
        this.roomOrderMapper.insert(roomOrder);
        return roomOrder;
    }

    /**
     * 修改数据
     *
     * @param roomOrder 实例对象
     * @return 实例对象
     */
    @Override
    public RoomOrder update(RoomOrder roomOrder) {
        this.roomOrderMapper.update(roomOrder);
        return this.queryById(roomOrder.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.roomOrderMapper.deleteById(id) > 0;
    }

    @Override
    public long queryRoomNumber(Integer userId) {
        long l = this.roomOrderMapper.queryRoomNumber(userId);
        return l;
    }


}

